import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:lepig/model/ProductModel.dart';
// 横排商品
class GoodsHorizontalOne extends StatelessWidget{
  GoodsHorizontalOne(this.productModel);
  ProductModel productModel;
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return  new Container(
      margin: EdgeInsets.only(top: 10.0),
      padding: EdgeInsets.all(10.0),
      decoration: new BoxDecoration(
        color: Colors.white,
      ),
      child: new GestureDetector(
        onTap: (){
          Navigator.pushNamed(context,"/product",arguments: productModel);
        },
        child:  new Flex(
          direction: Axis.horizontal,
          children: <Widget>[
            new Container(
              child: new Image.network(productModel.pic,fit: BoxFit.contain),
              width: 120.0,
              height: 100.0,
              margin: EdgeInsets.only(right: 10.0),
            ),
            new Expanded(
              flex: 1,
              child: new Column(
                children: <Widget>[
                  new Container(
                    child: new Text(productModel.title,style: TextStyle(
                      fontSize: 14.0,
                      fontWeight: FontWeight.w500,
                    ),
                      maxLines: 2,
                      overflow: TextOverflow.ellipsis,),
                    height: 45.0,

                  ),
                  new Flex(direction: Axis.horizontal,

                    children: <Widget>[
                      new Expanded(
                        flex: 1,
                        child: new Container(
                          alignment: Alignment.center,
                          height: 25.0,
                          padding: EdgeInsets.only(left: 5.0,right: 5.0),
                          decoration: BoxDecoration(
                            color: Color.fromRGBO(254, 84, 85,1),
                            borderRadius: BorderRadius.only(topLeft: Radius.circular(10.0),bottomLeft:Radius.circular(10.0) ),
                          ),
                          child: new Text("券￥"+productModel.couponPrice,style: TextStyle(
                              color: Colors.white,
                              fontSize: 13.0
                          ),),
                        ),
                      ),
                      new Expanded(
                        flex: 1,
                        child:  new Container(
                          height: 25.0,
                          padding: EdgeInsets.only(left: 5.0,right: 5.0),
                          alignment: Alignment.center,
                          decoration: BoxDecoration(
                              borderRadius: BorderRadius.only(topRight: Radius.circular(10.0),bottomRight:Radius.circular(10.0) ),
                              gradient: LinearGradient(colors: [Color.fromRGBO(250, 231, 33,1), Color.fromRGBO(254, 206, 2,1)], begin: FractionalOffset(1, 0), end: FractionalOffset(0, 1))
                          ),

                          child: new Text("返"+productModel.returnPrice+"元",style: TextStyle(
                              color:  Color.fromRGBO(140, 77, 0,1),
                              fontSize: 13.0

                          )),
                        ),
                      )
                    ],
                  ),
                  new SizedBox(height: 5.0,),
                  new Flex(
                    direction: Axis.horizontal,
                    children: <Widget>[
                      new Expanded(
                        flex: 1,
                        child:  new Row(
                          children: <Widget>[
                            new Text("券后 ",
                              style: TextStyle(
                                  color: Color.fromRGBO(254, 78, 80,1),
                                  fontSize: 12.0
                              ),
                            ),

                            new Text("￥",style: TextStyle(
                                color: Color.fromRGBO(254, 78, 80,1),
                                fontSize: 13.0,
                                fontWeight: FontWeight.bold
                            ),),

                            new Text(productModel.finalPrice,style: TextStyle(
                                color: Color.fromRGBO(254, 78, 80,1),
                                fontSize: 18.0,
                                fontWeight: FontWeight.bold
                            ),),
                            new SizedBox(
                              width: 10.0,
                            ),
                            new Text(" ￥"+productModel.originalPrice,
                              style: TextStyle(
                                  color: Color.fromRGBO(189, 188, 188,1),
                                  decoration: TextDecoration.lineThrough,
                                  fontSize: 12.0
                              ),
                            ),
                          ],
                        ),
                      ),
                      new Container(
                        width: 70.0,
                        child:new Text(productModel.sale+"人购买",style: TextStyle(
                            color: Color.fromRGBO(189, 188, 188,1),
                          fontSize: 10.0
                        ),) ,
                      )

                    ],
                  )

                ],
              ),
            )
          ],

        ),
      ),
    );
  }

}